﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "教师门户 - 网上成绩提交 - 补考成绩");
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		
		teacherId = sessionAdvice.getAutherUserID();
		
		termId = event.getArg("TermID");
		
		/* 补考成绩提交设置 */
		sql = "SELECT 
					a.mt,a.date_start,
					a.date_end,a.time_start,
					a.time_end,a.institute_allowed,
					a.lease_date 
			   FROM 
			   		t_mark_turn a 
			   WHERE 
			   		a.mt =:mt ";
					
		queryObj = new Query( datasource=application.dnsSlave ); 
		
		queryObj.addParam( name="mt", value="R", cfsqltype="cf_sql_char" );
		
		rs_turnSetting = queryObj.execute( sql=sql ).getResult();
	
		
		/*读取当前学期补考成绩录入记录*/
		sql = "	SELECT b.task_id, b.task_type,b.task_prog,
					  b.mark_done, b.mark_need, 
  	   				  d.course_name, d.course_credit, 
  		 			  d.course_code, b.cidx,e.institute_short, 
  		 			  d.mark_mode,e.institute_id 
				FROM t_resitplan b 
    				 INNER JOIN t_course d ON b.cid = d.cid 
     				 INNER JOIN t_institute e ON d.institute_id=e.institute_id
				WHERE
     				 b.term_id =:termId 
					 AND 
					 EXISTS (
						 SELECT 1 
						 FROM t_task a 
						 WHERE 
								 a.tsk_id = b.task_id 
						 AND 
								 (
									 a.tch_id =:teacherId OR a.tch_id_sec =:teacherId OR a.tch_id_ace =:teacherId 
								 )
						 AND 
						 SUBSTR(a.task_prop, 7, 1) = '0' 
					 ) 
					 OR 
					 EXISTS (
						SELECT 1 
						FROM t_common_task c 
						WHERE 
								c.tsk_id = b.task_id 
						AND 
								 (
									 c.tch_id =:teacherId OR c.tch_id_sec =:teacherId OR c.tch_id_ace =:teacherId 
								 )
						AND 
						SUBSTR(c.task_prop, 7, 1) = '0' 
					 )
					 OR 
					 EXISTS (
						SELECT 1 
						FROM t_reopen_task f 
						WHERE 
								 f.tsk_id = b.task_id 
						AND 
								 ( 
									f.tch_id =:teacherId OR f.tch_id_sec =:teacherId OR f.tch_id_ace =:teacherId 
								 )
						AND 
						SUBSTR(f.task_prop, 7, 1) = '0'
					 )
					 ORDER BY b.task_type, d.course_name,b.cidx ";
					 
		queryObj = new Query( datasource=application.dnsSlave ); 
		
		queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		
		rs_task = queryObj.execute( sql=sql ).getResult(); 
		
		
			
		/*读取历史补考任务录入任务*/									
		sql = " SELECT 
					   a.task_id,a.task_type,a.task_prog,
					   a.mark_done,a.mark_need,b.course_name,
					   b.course_credit,b.course_code,
					   a.cidx,c.institute_short,b.mark_mode,
					   c.institute_id 
				FROM
					t_resitplan a  
					INNER JOIN t_course b ON a.cid = b.cid 
					INNER JOIN t_institute c ON b.institute_id = c.institute_id 
				WHERE
					 a.term_id < :termId 
					 AND 
					 (
					 EXISTS 
					 (
						SELECT 1 
						FROM
							t_task d 
						WHERE 
							 d.tsk_id = a.task_id 
							 AND 
							 (
							  d.tch_id = :teacherId OR d.tch_id_sec = :teacherId OR d.tch_id_ace = :teacherId  
							 )
							 AND 
							 SUBSTR(d.task_prop, 7, 1) = '0' 
					  )
					  OR 
					  EXISTS 
					  (
						 SELECT 1 
						 FROM t_common_task e 
						 WHERE
							  e.tsk_id = a.task_id 
							  AND 
							  (
								 e.tch_id = :teacherId OR e.tch_id_sec = :teacherId OR e.tch_id_ace = :teacherId 
							  ) 
							  AND 
							  SUBSTR(e.task_prop, 7, 1) = '0' 
					  )
					  OR 
					  EXISTS 
					  (
							SELECT 1 
							FROM t_reopen_task f 
							WHERE 
								 f.tsk_id = a.task_id 
								 AND 
								 (
									 f.tch_id = :teacherId OR f.tch_id_sec = :teacherId OR f.tch_id_ace = :teacherId 
								 )
					  )
					 )
					 ORDER BY a.task_type,b.course_name,a.cidx ";
					 
		queryObj = new Query( datasource=application.dnsSlave ); 
		
		queryObj.addParam( name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar" );
		queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
		
		rs_taskHis = queryObj.execute( sql=sql ).getResult(); 			 
		
											
		
		/* 判断当前显示标签内容 */
		currentTab = event.getArg("TabID", "labCurrent");
		
		targetArgs = structNew();
		
		currentDate = datetimeAdvice.getCurrentDateString();
		currentTime = TimeFormat(now(), "HHMM");
		
		/*读取学院信息*/
		if( rs_turnSetting.institute_allowed neq "ALL"){
		
			sql="   SELECT a.institute_short 
					FROM t_institute a
					WHERE 
						a.institute_id IN(:insIds )";
						
			queryObj = new Query( datasource=application.dnsSlave ); 
			
			queryObj.addParam( name="insIds", value= rs_turnSetting.institute_allowed, cfsqltype="cf_sql_varchar",list=true );
			
			rs_insSelect = queryObj.execute( sql=sql ).getResult();
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('courseTask')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 exam"></i>需提交课程补考成绩任务
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labCurrent">class="active"</cfif> id="labCurrent" tabTarget="Current">课程补考成绩</span>
						<cfif rs_taskHis.recordCount>
							<span <cfif currentTab eq "labHistory">class="active"</cfif> id="labHistory" tabTarget="History">历史补考成绩</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					// -->
					//]]>
				</script>
				
				<div id="Current" class="tabContent">
					
					<div class="noticeBlock">
						<h3>补考成绩录入时间段安排</h3>
						<p>
							<span class="img icon16x16 message"></span>
							课程补考成绩提交
							从 
							<em><cfoutput>#datetimeAdvice.formatDateString( rs_turnSetting.date_start )#</cfoutput></em>
							至
							<em><cfoutput>#datetimeAdvice.formatDateString( rs_turnSetting.date_end )#</cfoutput></em>
								
							<cfif rs_turnSetting.time_start eq "0001" and rs_turnSetting.time_end eq "2359">
									全天
								<cfelse>
									每天
									<em><cfoutput>#datetimeAdvice.formatTimeString( rs_turnSetting.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString( rs_turnSetting.time_end, 'HH:MI')#</cfoutput></em>
							</cfif>
							.
							开课学院: 
							<cfif rs_turnSetting.institute_allowed eq "ALL">
								全部
								<cfelse>
                                    <cfoutput>#valueList(rs_insSelect.institute_short, " | ")#</cfoutput>
							</cfif>
							.
							您需要提交课程考核成绩的教学任务安排如下.</p>
						<hr/>
					</div>
					
					<cfif rs_task.recordCount>

							<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td width="50">部门</td>
										<td>课程</td>
										<td width="90">课程号</td>
										<td width="50">课序号</td>
										<td width="40">学分</td>
										<td width="60">提交进度</td>
										<td width="60">计分模式</td>
										<td width="60">状态</td>
										<td width="18"></td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />
                                
                                    <cfloop query="rs_task">
										<cfset row++ />
										<cfset structInsert(targetArgs, "TSK", rs_task.task_id, true) />
										<cfset structInsert(targetArgs, "TT", rs_task.task_type, true) />
										<cfset structInsert(targetArgs, "Sign", encrypt(rs_task.task_id, teacherId, "PBEWithMD5AndDES", "Hex"), true) />
										<tr class="editRows" rowid="<cfoutput>#rs_task.task_id#</cfoutput>">
											<td class="index"><cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
											<td><cfoutput>#rs_task.course_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_task.course_code#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#rs_task.cidx#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#numberFormat(rs_task.course_credit, '_.__')#</cfoutput></span></td>
											<td align="center"><span class="numeric"><cfoutput>#rs_task.mark_done#</cfoutput> / <cfoutput>#rs_task.mark_need#</cfoutput></span></td>
											<td align="center"><cfoutput>#dictAdvice.getMarkModeName( rs_task.mark_mode )#</cfoutput></td>
											<td><cfoutput>#dictAdvice.getTaskMarkStat( rs_task.task_prog )#</cfoutput></td>
											<td>
												<cfif rs_task.task_prog eq "3">
													<a title="打印课程成绩" href="<cfoutput>#buildURL('taskMarkResitPrint', targetArgs)#</cfoutput>" class="stat print" target="_blank"></a>
												</cfif>
											</td>
											<td>	
												<!--- 判断成绩提交时段 --->
												<cfif (rs_task.task_prog neq "3") and ( rs_turnSetting.time_start lte currentTime and currentTime lte rs_turnSetting.time_end ) and ( rs_turnSetting.date_start lte currentDate and currentDate lte rs_turnSetting.date_end) >
													<!--- 开课学院在允许的范围内 --->
													<cfif ( rs_turnSetting.institute_allowed eq "ALL" or listFind(rs_turnSetting.institute_allowed, rs_task.institute_id, ",") )>
														<a title="提交课程成绩" href="<cfoutput>#buildURL('taskMarkResitHandel', targetArgs)#</cfoutput>" class="stat publish"></a>
													</cfif>
												</cfif>
											</td>
										</tr>
									</cfloop>
								</tbody>
							</table>
							
						<cfelse>
							
							<div class="systemNotice">
								<h3>没有需要提交补考成绩的教学任务</h3>
							</div>
									
					</cfif>
					
				</div>
				
				<cfif rs_taskHis.recordCount>

					<div id="History" class="tabContent">
						
						<div class="noticeBlock">
							<h3>历史补考成绩</h3>
							<p>
								<span class="img icon16x16 message"></span>
								课程补考成绩提交
								从 
								<em><cfoutput>#datetimeAdvice.formatDateString( rs_turnSetting.date_start )#</cfoutput></em>
								至
								<em><cfoutput>#datetimeAdvice.formatDateString( rs_turnSetting.date_end )#</cfoutput></em>
								
								<cfif rs_turnSetting.time_start eq "0001" and rs_turnSetting.time_end eq "2359">
										全天
									<cfelse>
										每天
										<em><cfoutput>#datetimeAdvice.formatTimeString( rs_turnSetting.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString( rs_turnSetting.time_end, 'HH:MI')#</cfoutput></em>
								</cfif>
								.
								开课学院: 
								<cfif rs_turnSetting.institute_allowed eq "ALL">
									全部
									<cfelse>
                                    	<cfoutput>#valueList(rs_insSelect.institute_short, " | ")#</cfoutput>
								</cfif>
								.
								下列是您参与的以往学年课程补考信息. </p>
							<hr/>
						</div>
						
						<table class="UIEditable">
								<thead>
									<tr>
										<td width="30"></td>
										<td width="50">部门</td>
										<td>课程</td>
										<td width="90">课程号</td>
										<td width="50">课序号</td>
										<td width="40">学分</td>
										<td width="60">提交进度</td>
										<td width="60">计分模式</td>
										<td width="60">状态</td>
										<td width="18"></td>
										<td width="18"></td>
									</tr>
								</thead>
								<tbody>
									<cfset row = 0 />
                            			<cfloop query="rs_taskHis">
										<cfset row++ />
										<cfset structInsert(targetArgs, "TSK", rs_taskHis.task_id, true) />
										<cfset structInsert(targetArgs, "TT", rs_taskHis.task_type, true) />
										<cfset structInsert(targetArgs, "Sign", encrypt(rs_taskHis.task_id, teacherId, "PBEWithMD5AndDES", "Hex"), true) />
										<tr class="editRows" rowid="<cfoutput>#rs_taskHis.task_id#</cfoutput>">
											<td class="index"><cfoutput>#row#</cfoutput></td>
											<td><cfoutput>#rs_taskHis.institute_short#</cfoutput></td>
											<td><cfoutput>#rs_taskHis.course_name#</cfoutput></td>
											<td><span class="numeric"><cfoutput>#rs_taskHis.course_code#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#rs_taskHis.cidx#</cfoutput></span></td>
											<td><span class="numeric"><cfoutput>#numberFormat(rs_taskHis.course_credit, '_.__')#</cfoutput></span></td>
											<td align="center"><span class="numeric"><cfoutput>#rs_taskHis.mark_done#</cfoutput> / <cfoutput>#rs_taskHis.mark_need#</cfoutput></span></td>
											<td align="center"><cfoutput>#dictAdvice.getMarkModeName( rs_taskHis.mark_mode )#</cfoutput></td>
											<td><cfoutput>#dictAdvice.getTaskMarkStat( rs_taskHis.task_prog )#</cfoutput></td>
											<td>
												<cfif rs_taskHis.task_prog eq "3">
													<a title="打印课程成绩" href="<cfoutput>#buildURL('taskMarkResitPrint', targetArgs)#</cfoutput>" class="stat print" target="_blank"></a>
												</cfif>
											</td>
											<td>	
												<!--- 判断成绩提交时段 --->
												<cfif (rs_taskHis.task_prog neq "3") and ( rs_turnSetting.time_start lte currentTime and currentTime lte rs_turnSetting.time_end ) and ( rs_turnSetting.date_start lte currentDate and currentDate lte rs_turnSetting.date_end) >
													<!--- 开课学院在允许的范围内 --->
													<cfif ( rs_turnSetting.institute_allowed eq "ALL" or listFind(rs_turnSetting.institute_allowed, rs_taskHis.institute_id, ",") )>
														<a title="提交课程成绩" href="<cfoutput>#buildURL('taskMarkResitHandel', targetArgs)#</cfoutput>" class="stat publish"></a>
													</cfif>
												</cfif>
											</td>
										</tr>
									</cfloop>
								</tbody>
							</table>
						
					</div>
				
				</cfif>
				
			</div>
		</li>
	</ul>
</div>





